#ifndef __COM_LOG_MANAGER_H__
#define __COM_LOG_MANAGER_H__

#include <fstream>
#include <sstream>
#include <string>

using namespace std;

#include <time.h> 

class LogManager : public ofstream
{
public:
	LogManager(const char * filename, ios_base::openmode mode = ios_base::in)
	:ofstream(filename,mode)
	{		
	}
};
extern LogManager myLoggerRef;

#define setLogFile(x,mode) LogManager myLoggerRef(x,mode );

#define __TIME_FILE_LINE__

#ifdef __TIME_FILE_LINE__

#define ttcode_log \
	{ \
		time_t log_t = time(0); \
		char tmpLog[64]; \
		struct tm *s_time; \
		s_time = localtime(&log_t); \
		strftime( tmpLog, sizeof(tmpLog), "%Y/%m/%d %X", s_time );\
													\
		myLoggerRef << tmpLog ;\
		myLoggerRef << "\t" << __FILE__ << ":" ;\
		myLoggerRef << __LINE__; \
		myLoggerRef << "\t\t" ; \
	} \
	myLoggerRef \

#else

#define ttcode_log \
	{ \
		time_t log_t = time(0); \
		char tmpLog[64]; \
		strftime( tmpLog, sizeof(tmpLog), "%Y/%m/%d %X",localtime(&log_t) );\
													\
		myLoggerRef << tmpLog ;\
		myLoggerRef << "\t\t" ; \
	} \
	myLoggerRef \


#endif // __TIME_FILE_LINE__

#define StringErrorMsg(x,y) ostringstream os; os<<" Error occured at: file " << __FILE__ << " " << __LINE__ \
	<< ".\t" << y; string x = os.str();\



#endif // __COM_LOG_MANAGER_H__
